﻿using NCP.Infrastructure.Common.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;

namespace NCP.Recruiting.WebApp.Extensions
{
    public static class Common
    {
        /// <summary>
        /// 生成DropDownList所需的数据源
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnumerable<SelectListItem> GenerateDropDownListSource(LovType type)
        {
            return LovHandler.GetListByParentId(LovHandler.GetLovId(type)).
                Select(x => new SelectListItem()
                {
                    Text = x.Name,
                    Value = x.Value.Value.ToString()
                });
        }


        public static IEnumerable<SelectListItem> GenerateDropDownSubListSource(int? lovValue)
        {
            return LovHandler.GetListByParentId(LovHandler.ConvertLovValueToGuid(lovValue.Value)).
                Select(x => new SelectListItem()
            {
                Text = x.Name,
                Value = x.Value.Value.ToString()
            });
        }
    }
}